package com.ruoyi.user.controller;

import com.ruoyi.common.core.exception.user.Result;
import com.ruoyi.user.entity.User;
import com.ruoyi.user.entity.UserInformation;
import com.ruoyi.user.service.UserInformationService;
import com.ruoyi.user.service.UserService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;

/**
 * @Author: 张桦阳
 * @Date: 2023-03-22-18:30:45
 * @Description: 类
 */
@RestController
public class UserController {

    @Resource
    private UserService userService;

    @Resource
    private UserInformationService userInformationService;

    @RequestMapping("/register")
    public Result register(@RequestBody User user){

        return userService.register(user);
    }

    @RequestMapping("/sendCode")
    public Result sendCode(@RequestParam("mobile")String mobile){
        return userService.sendCode(mobile);
    }

    @RequestMapping("/login")
    public Result login(@RequestBody User user, HttpSession session) throws UnsupportedEncodingException {
        return userService.login(user,session);
    }

    @RequestMapping("/saveInfomation")
    public Result saveInfomation(@RequestBody UserInformation userInformation){
        return userInformationService.saveInfomation(userInformation);
    }
}
